import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

// state
let state = {
  global: {},
  roleInfo: {}
}

// getters
const getters = {
  global: state => state.global
}

// actions
const actions = {
  getUserInfo ({ commit }, params) {
    commit('CHECK_ACCOUNT', {params})
  }
}

// mutations
const mutations = {
  CHECK_ACCOUNT (state, {data}) {
    state.roleInfo = data
  }
}

const store = new Vuex.Store({
  state,
  actions,
  getters,
  mutations
})

store.registerModule('vux', { // 名字自己定义
  state: {
    isLoading: false
  },
  mutations: {
    updateLoadingStatus (state, payload) {
      state.isLoading = payload.isLoading
    }
  }
})

export default store
